package com.browsesoft.htmlcomponent;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.w3c.dom.Element;

import com.browsesoft.user.User;

public class PersonalAddrListComponent extends HTMLFormComponent {
	User userName = null;

	/**
	 * 构造
	 * 
	 * @param parent
	 * @throws Exception
	 */

	public PersonalAddrListComponent(HTMLBasicComponent parent)
			throws Exception {
		super(parent);
	}

	/**
	 * 处理用户请求，将需要Model处理的内容提交给Model，将请求的名字值对中的名字转为小写
	 * 
	 * @param request
	 *            客户端请求
	 * @throws java.lang.Exception
	 */
	public void service(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		super.service(request, response);
		// 得到用户id
		userName = (User) request.getSession().getAttribute("loginUser");
	}

	protected void updateElement() throws Exception {
		super.updateElement();
		Element element = (Element) this.element.getElementsByTagName("person")
				.item(0);
		Element sonElement = (Element) element.getElementsByTagName("input")
				.item(0);
		String value = sonElement.getAttribute("value");
		value = (String) userName.getID();
		sonElement.setAttribute("value", value);
	}
}